
local function _sum(array)
    if next(array) == nil then
        return 0
    else
        return array[1] + _sum(table.move(array, 2, #array, 1, {}))
    end
end

local function test()
    local sum = 0
    local arr = {}
    for i=1, 5 do
        arr[#arr+1] = i
        sum = sum + i
    end

    local sum2 = _sum(arr)
    assert(sum == sum2)
end

test()

